package com.nbsaas.boot.evaluate.rest.convert;

import com.nbsaas.boot.entity.evaluate.EvaluateCatalog;
import com.nbsaas.boot.evaluate.api.domain.simple.EvaluateCatalogSimple;

import com.nbsaas.boot.rest.api.Converter;
    import java.util.stream.Collectors;
    import lombok.Data;

/**
* 评价分类-列表对象转换器
*/

    @Data
public class EvaluateCatalogSimpleConvert implements Converter<EvaluateCatalogSimple, EvaluateCatalog> {


    private int fetch;


@Override
public EvaluateCatalogSimple convert(EvaluateCatalog source) {
    EvaluateCatalogSimple result = new EvaluateCatalogSimple();


               try {
                   if(source.getParent()!=null){
                       result.setParent(source.getParent().getId());
                   }
                } catch (Exception ignored) { }

                result.setCode(source.getCode());
                result.setIcon(source.getIcon());
                result.setDescription(source.getDescription());
                result.setAddDate(source.getAddDate());

                try {
                    if(source.getParent()!=null){
                        result.setParentName(source.getParent().getName());
                    }
                } catch (Exception ignored) { }

                result.setDepth(source.getDepth());
                result.setEvaluateCount(source.getEvaluateCount());
                result.setName(source.getName());
                result.setIds(source.getIds());
                result.setSortNum(source.getSortNum());
                result.setId(source.getId());
                result.setLft(source.getLft());
                result.setRgt(source.getRgt());
                result.setLastDate(source.getLastDate());

        result.setLabel(source.getName());
        result.setValue(""+source.getId());
        if (result.getCode()==null){
           result.setCode("");
        }

    return result;
}

}